package com.richinfo.consumer.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

/**
* Created by WangXJ
* 2018-11-01 17:12
*/
@Service
public class HelloService {
	
	@Resource
	private RestTemplate restTemplate;
	
	@HystrixCommand(fallbackMethod = "helloFallback")
	public String sayHello() {
		return restTemplate.getForEntity("http://hello-service/hello", String.class).getBody();
	}
	
	public String helloFallback() {
		return "error";
	}
}
